package com.yc.jpa;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.core.RepositoryInformation;


public class JpqlBeanMethodInterceptor implements MethodInterceptor {
    /**
    * 用于存放QueryMethod对应的字段和返回类型信息
    */
//    private Map<Method, SelectAlias> selectAlias = new HashMap<>();
//
//    public JpqlBeanMethodInterceptor(RepositoryInformation repositoryInformation) {
//        Iterator<Method> iterable = repositoryInformation.getQueryMethods().iterator();
//        SqlParser sqlParser = new DefaultSqlParser();
//        while (iterable.hasNext()) {
//            Method method = iterable.next();
//            Query query = method.getAnnotation(Query.class);
//            if (query == null || query.nativeQuery()) {
//                continue;
//            }
//            //获取返回类型
//            Class clazz = getGenericReturnClass(method);
//            if (clazz == null) {
//                continue;
//            }
//            SelectAlias alias = sqlParser.getAlias(query.value(), clazz);
//            if (alias == null) {
//                continue;
//            }
//            selectAlias.put(method, alias);
//        }
//    }

	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		
		return null;
	}


}
